<?php 
namespace  Admin\Model;
use Think\Model;

class CateModel extends Model{
	
	public $cats = array();

	public function __construct(){
		parent::__construct();//防止重写父类中的construct方法
		$this->cats = $this->select();
	}
	public function catelist($parent_id = 0, $evl=0){
		$tree = array();
		foreach($this->cats as $c){
			if($c['parent_id'] == $parent_id){
				$c['evl'] = $evl;
				$tree[] = $c;
				$tree = array_merge($tree,$this->catelist($c['cat_id'],$evl+1));	
			}
		}
		return $tree;
	}
}

?>